package banking;

public class Account {
  private double balance;
  public Account (double bal) {
	balance= bal;
  }
	public double getBalance() {
	  return balance;
	}
	public boolean deposit (double amount) {
	  balance = balance + amount;
	  return true;
	}
	public boolean withdraw(double amount) {
	  boolean result = true;
	  if ( balance < amount ) {
	    result = false;
	} else {
	  balance = balance- amount;
	}
	return result;
  }
   // 添加 main 方法用于测试 Account 类
    public static void main(String[] args) {
        Account acc = new Account(1000.0);
        System.out.println("初始余额: " + acc.getBalance());

        acc.deposit(500.0);
        System.out.println("存入 500.0 后余额: " + acc.getBalance());

        boolean success = acc.withdraw(200.0);
        System.out.println("取款 200.0: " + (success ? "成功" : "失败"));
        System.out.println("当前余额: " + acc.getBalance());

        success = acc.withdraw(2000.0);
        System.out.println("取款 2000.0: " + (success ? "成功" : "失败"));
        System.out.println("最终余额: " + acc.getBalance());
    }

}
